# Contributor: Taner Tas <taner76@gmail.com>
# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=emulationstation
_pkgname="EmulationStation"
pkgver=2.7.6
pkgrel=1
pkgdesc="EmulationStation is a cross-platform graphical front-end for emulators with controller navigation."
url="https://github.com/RetroPie/EmulationStation"
arch="all !armhf !s390x !mips !mips64" # vlc-dev
license="MIT"
makedepends="boost-dev freeimage-dev freetype-dev sdl2-dev mesa-dev alsa-lib-dev vlc-dev curl-dev cmake"
_theme_name="gbz35"
_theme_commit="49176c4b3dbe103da84bd29ef474fd3c9f60a8de"
_pugixml_commit="f3139f4c0487a7455d66d4dcd3b0aab3d54c63d1"
subpackages="$pkgname-theme-$_theme_name:theme:noarch"
options="!check" # No test suite

source="$pkgname-$pkgver.tar.gz::https://github.com/RetroPie/$_pkgname/archive/v$pkgver.tar.gz
	$pkgname-theme-$_theme_name-$_theme_commit.tar.gz::https://github.com/rxbrad/es-theme-$_theme_name/archive/$_theme_commit.tar.gz
	pugixml-$_pugixml_commit.tar.gz::https://github.com/zeux/pugixml/archive/$_pugixml_commit.tar.gz
	default-paths.patch
	emulationstation.desktop
	emulationstation.png"
builddir="$srcdir"/$_pkgname-$pkgver

prepare() {
	if [ ! -d external/pugixml.dist ]; then
		mv -f external/pugixml external/pugixml.dist
		cp -aP "$srcdir"/pugixml-$_pugixml_commit external/pugixml
	fi
	default_prepare
}

build() {
	cmake .
	make
}

package() {
	depends="$pkgname-theme-default"
	mkdir -p "$pkgdir"/usr/bin
	mkdir -p "$pkgdir"/usr/share/pixmaps
	mkdir -p "$pkgdir"/usr/share/applications
	mkdir -p "$pkgdir"/usr/share/$pkgname/gamelists
	mkdir -p "$pkgdir"/usr/share/$pkgname/themes
	install -Dm755 emulationstation "$pkgdir"/usr/bin/emulationstation
	install -Dm644 "$srcdir"/$pkgname.png "$pkgdir"/usr/share/pixmaps/
	install -Dm644 "$srcdir"/$pkgname.desktop "$pkgdir"/usr/share/applications/
}

theme() {
	pkgdesc="$_theme_name theme for $_pkgname"
	license="CC-BY-NC-SA-3.0"
	url="https://github.com/rxbrad/es-theme-gbz35"
	provides="$pkgname-theme-default"

	install -d -m755 "$subpkgdir"/usr/share/$pkgname/themes
	cp -r "$srcdir"/es-theme-$_theme_name-$_theme_commit \
		"$subpkgdir"/usr/share/$pkgname/themes/$_theme_name
}
sha512sums="9df1573d172b8a77a478283fad040d4ed535ba5ca90cf1d215e2d2eb0d258247e57c732a99034dc58d4b12afba2892d34f9f6c36c47a1b155b6328d4246e7cd9  emulationstation-2.7.6.tar.gz
012beb7511e54786911de21b092b6c271aef44ac196b6c3a1e6be3eb6dad5cedef41ed1ae2652befc9486c851eca75dc025da42e0c59e5656adf5c02b3148d95  emulationstation-theme-gbz35-49176c4b3dbe103da84bd29ef474fd3c9f60a8de.tar.gz
bc6ab2f39c7414e5baca2917710a7e5e280aef2562afeec93adcb01424512fba6682531e8fd9b9e5e6e08841433e5e390e832560400bafafd3b45ff9355f43ad  pugixml-f3139f4c0487a7455d66d4dcd3b0aab3d54c63d1.tar.gz
3c0fe93a76fe2f702cdc1870ebfe12b3305ba24a75e90ea6dde6d479c654f662d210e5b35ce3451f3f03902ebbaeb27d117e8ca94f5b117748bcd286f37bae39  default-paths.patch
814a196d234266809f2c3f64c7179e3138e017eb67d1c54dcc2e8c504c1439cb73f17352575cd582ce044b08405f3a369d049127c9f4c5a1336072435dfa54f0  emulationstation.desktop
4a24c435aeef22d7d69c3af113bff97c2c99b4a1eb2e5c97f53a6cce1f11a4f92bf4250388598a89f8fd462e03ea6fc73b75739573faf6f7b30c98ab53ddb5bf  emulationstation.png"
